package com.code.family.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class ResultVo {
    private String code;
    private String msg;
    private Object data;


    public static ResultVo success() {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode("200");
        resultVo.setMsg("请求成功");
        return resultVo;
    }

    public static ResultVo success(String msg) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode("200");
        resultVo.setMsg(msg);
        return resultVo;
    }

    public static ResultVo success(Object data) {
        ResultVo resultVo = success();
        resultVo.setData(data);
        return resultVo;
    }

    public static ResultVo success(String msg, Object data) {
        ResultVo resultVo = success(msg);
        resultVo.setData(data);
        return resultVo;
    }

    public static ResultVo error() {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode("500");
        resultVo.setMsg("请求失败");
        return resultVo;
    }

    public static ResultVo error(String msg) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode("500");
        resultVo.setMsg(msg);
        return resultVo;
    }

}
